package repeat.personal.util;

import java.io.File;

/**
 * 描述:
 *
 * @author Zhanggq
 * @date 2019/6/15 12:13
 */
public class SystemInfoUtils {
    private SystemInfoUtils() {
    }

    /**
     * 判断系统版本是否为Windows
     * @return
     */
    public static Boolean isWindowPlatform(){
        if (System.getProperties().getProperty("os.name").toLowerCase().contains("windows")){
            return true;
        }else{
            return false;
        }

    }
    /**
     * 生成uuid文件名+.后缀
     * abc.txt   /data/2018/03/uuid
     * @return
     */
    public static String createUUIDName(String name ){
        String UUIDName;
        if (name.lastIndexOf(".") == -1) {
            UUIDName =  StringUtils.getUUID();
        } else {
            UUIDName =  StringUtils.getUUID() + "."+ StringUtils.substringAfterLast(name,".");
        }
        return UUIDName;
    }

    /**
     * 获取本地存储路径
     * @return
     */
    public static String getLocalPath() {
        String localPath;
        if (SystemInfoUtils.isWindowPlatform()) {
            localPath = "D:\\data\\manual\\";
        } else {
            localPath = "/data/manual/";
        }
        File file = new File(localPath);
        //不存在路径
        if (!file.exists()) {
            file.mkdirs();
        }
        return localPath;
    }

    /**
     * 获取本地临时存储路径
     * @return
     */
    public static String getTmpStorePath(){
        String tmpStorePath;
        if (SystemInfoUtils.isWindowPlatform()){
            tmpStorePath="D:\\manual_data\\tmp\\";
        }else {
            tmpStorePath="/manual_data/tmp/";
        }
        File file=new File(tmpStorePath);
        if (!file.exists()){
            file.mkdirs();
        }
        return tmpStorePath;
    }

}
